# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Filipe Nascimento <flipee at tuta dot io>

pkgname=choose
pkgver=1.3.4
pkgrel=1
pkgdesc='A human-friendly and fast alternative to cut and (sometimes) awk'
arch=('loong64' 'x86_64')
url="https://github.com/theryangeary/choose"
license=('GPL3')
depends=('gcc-libs')
makedepends=('git' 'rust')
checkdepends=('diffutils')
options=('!lto')
_commit='d434bd289d043997058d9a08d5e02642060fcde9'
source=("$pkgname::git+$url.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname"

  cargo build --frozen --release
}

check() {
  cd "$pkgname"

  cargo test --frozen --release

  ./test/e2e_test.sh
}

package() {
  cd "$pkgname"

  install -vDm755 -t "$pkgdir/usr/bin" target/release/choose

  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" readme.md
}
